﻿using SIAKADCORE.Helpers;
using SIAKADCORE.Models;
using System;
using System.Collections.Generic;
using System.Data;
using System.Linq;
using System.Text;
using System.Threading.Tasks;

namespace SIAKADCORE.Controllers
{
    public static class PengaturanPertanyaanController
    {


        public static bool GetTabel(out DataSet dataset)
        {
            string queryString = string.Format("SELECT {0}, {1}, {2}, {3} FROM {4}", DetailPertanyaan.ColumnNameIdDetailPertanyaan, DetailPertanyaan.ColumnNameIdPengambilanMatakuliah, DetailPertanyaan.ColumnNameIdPemilihanPertanyaan, DetailPertanyaan.ColumnNameIdJawaban, DetailPertanyaan.TableName);
            return SQLHelper.Instance.ExecuteReader(queryString, out dataset);
        }

        public static bool GetTabel(out DataSet dataset, string customQueryString)
        {
            return SQLHelper.Instance.ExecuteReader(customQueryString, out dataset);
        }

        public static bool Hapus(String IdPertanyaan)
        {
            string queryString = String.Format("DELETE FROM {0} WHERE {1} = '{2}'", DetailPertanyaan.TableName, DetailPertanyaan.ColumnNameIdPemilihanPertanyaan, IdPertanyaan);
            return SQLHelper.Instance.ExecuteNonQuery(queryString);
        }

        public static bool GetTabelPreview(out DataSet dataset, string thn,  string prt)
        {
            string queryString = string.Format("select distinct pertanyaan.pertanyaan from detail_pertanyaan, pertanyaan, detail_pengambilan_matakuliah, detail_matakuliah, tahun, matakuliah  where  detail_pertanyaan.id_detail_pengambilan_matakuliah = detail_pengambilan_matakuliah.id_detail_pengambilan_matakuliah and detail_pertanyaan.id_pertanyaan = pertanyaan.id_pertanyaan and detail_pengambilan_matakuliah.id_detail_matakuliah =  detail_matakuliah.id_detail_matakuliah and detail_matakuliah.id_matakuliah = matakuliah.id_matakuliah and detail_matakuliah.id_tahun = tahun.id_tahun");
            return SQLHelper.Instance.ExecuteReader(queryString, out dataset);
        }



    }
}
